<template>
	<view>
		<view class="">
			<u-navbar bgColor="transparent" :fixed="false" autoBack>
			</u-navbar>
		</view>
		<view class="flex-cen">
			<image src="../static/images/success.png" style="width: 52rpx;height: 52rpx;"></image>
			<text class="f36 fw500 ml20">购买成功</text>
		</view>
		<view class="box">
			<view class="flex-jus">
				<text class="textoverflow f32 fw500">{{detail.orderPro.proName}}</text>
				<view class="flex f24" @click="openUrl('/subpage/order/tuangouDetail?id='+detail.id)">
					<text>查看订单</text>
					<image src="../static/images/righton.png" style="width: 32rpx;height: 32rpx;"></image>
				</view>
			</view>
			<view class="flex-cen flex-col bordertop mt20">
				<image class="mt30" :src="api_host+detail.qrcode"
					style="width: 377rpx;height: 377rpx;border-radius: 15rpx;"></image>
				<view class="mt20 f32">
					<text class="fw500">券码</text>
					<text class="ml10">{{detail.orderCode}}</text>
					<text class="blue ml10" @click="fuzhi(detail.orderCode)">复制</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getOrderdetail
	} from '@/common/api_order.js'
	export default {
		data() {
			return {
				detail: {}
			}
		},
		onLoad(option) {
			this.id = option.id
		},
		onShow() {
			if (this.id) {
				this.getOrderdetail()
			}
		},
		methods: {
			async getOrderdetail() {
				uni.showLoading({
					mask: true
				})
				const res = await getOrderdetail({
					id: this.id
				})
				if (res.code == 200) {
					this.detail = res.data
					// const {
					// 	userAddr,
					// 	orderDetails,
					// 	orderPro,
					// 	sceneImages,
					// 	goodsInfo,
					// } = this.detail
					// this.detail.employVal = goodsInfo.goodEmployValues.split(',')
					// this.detail.goodsGroupsOne = goodsInfo.goodsGroups[0]
					// this.detail.goodsGroupsMore = goodsInfo.goodsGroups.splice(0, 1)
					// this.detail.buyNoticesOne = goodsInfo.buyNotices[0]
					// this.detail.buyNoticesMore = goodsInfo.buyNotices.splice(0, 1)
					// this.detail.oneStore = goodsInfo.goodsStores[0]
					// if (this.detail.orderStatus == 0) {
					// 	let nowTimes = new Date().getTime()
					// 	let createTime = this.detail.createTime.replace(/-/g, "/")
					// 	let orderTimes = new Date(createTime).getTime()
					// 	let times30 = 30 * 60 * 1000
					// 	this.detail.downTimes = orderTimes + times30 - nowTimes
					// }
				}
				uni.hideLoading()
			},
			fuzhi(val) {
				uni.setClipboardData({
					data: val,
					success: function(res) {
						uni.getClipboardData({
							//这个api是把拿到的数据放到剪切板中的
							success: function(res) {
								wx.showToast({
									title: '复制成功',
									icon: "none",
								})
							}
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.box {
		width: 688rpx;
		height: 585rpx;
		background: #FFFFFF;
		border-radius: 38rpx;
		padding: 30rpx;
		box-sizing: border-box;
		margin: 20rpx auto;
	}
</style>